#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;

class Solution {
public:
    int maxFrequencyElements(vector<int>& nums) {
        unordered_map<int, int> umap;
        int countMax = 0;
        long long ans = 0;
        for (auto& e : nums) {
            umap[e]++;
        }
        for (auto& count : umap) {
            if (count.second > countMax) {
                countMax = count.second;
            }
        }
        for (auto& e : umap) {
            if (e.second == countMax) {
                ans += countMax;
            }
        }
        return ans;
    }
};